package com.nercel.dsj.gksales.dao.mapper;

import com.nercel.dsj.gksales.model.QueryParams;
import com.nercel.dsj.gksales.model.entity.Role;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author sunlin
 * @date 2018-11-15
 */
@Mapper
@Repository
public interface RoleMapper {

    int deleteByPrimaryKey(Integer id);

    int insert(Role record);

    int insertSelective(Role record);

    Role selectByPrimaryKey(Integer id);

    Role selectByIdWithPermissions(Integer id);

    int updateByPrimaryKeySelective(Role record);

    int updateByPrimaryKey(Role record);

    List<Role> query(QueryParams params);

    List<Role> selectByUserId(Integer id);

    List<Role> selectByUserIdWithPermissions(Integer id);

    /**
     * 更新全部权限
     * @param roleId
     * @param ids
     * @return
     */
    int updatePermissions(@Param(value = "roleId") Integer roleId, @Param(value = "ids") List<Integer> ids);

    int batchInsertPermissions(@Param(value = "roleId") Integer roleId, @Param(value = "ids") List<Integer> ids);

    int deletePermission(@Param(value = "roleId") Integer roleId, @Param(value = "permissionId") Integer permissionId);

}
